package cn.edu.zjut.mina.po;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;

@Table(name="t_everyGameResult")
@Entity
public class EveryGameResult {
	private Integer everyGameResultId;//本局游戏的Id  (主键)
	//private String totalGameResultId;//这一局的游戏结果对应的游戏Id   (外键)
	@JSONField(serialize=false)//解决相互引用带来的无限Json解析的问题
	private TotalGameResult totalGameResult;//这一局的游戏结果对应的游戏   (外键)
	private List<PlayerBattleInfo> playerBattleInfos;//一局游戏中包含的所有玩家的对局信息
	
	@GeneratedValue
	@Id
	public Integer getEveryGameResultId() {
		return everyGameResultId;
	}
	public void setEveryGameResultId(Integer everyGameResultId) {
		this.everyGameResultId = everyGameResultId;
	}
	
	@ManyToOne(cascade = CascadeType.PERSIST, optional=true,fetch = FetchType.LAZY)
	@JoinColumn(name="totalGameResult_id", referencedColumnName="totalGameResultId")
	public TotalGameResult getTotalGameResult() {
		return totalGameResult;
	}
	public void setTotalGameResult(TotalGameResult totalGameResult) {
		this.totalGameResult = totalGameResult;
	}
	
	@OneToMany(mappedBy = "everyGameResult", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public List<PlayerBattleInfo> getPlayerBattleInfos() {
		return playerBattleInfos;
	}
	public void setPlayerBattleInfos(List<PlayerBattleInfo> playerBattleInfos) {
		this.playerBattleInfos = playerBattleInfos;
	}
}
